///////////////////////////////////////////////////////////
//  ControlCommand.h
//  Implementation of the Class ControlCommand
//  Created on:      21-Sep-2013 12:06:49 PM
//  Original author: Jakkaphan Aiemcharoenjit
///////////////////////////////////////////////////////////

#if !defined(EA_B9C3BDB6_E1AE_4cf2_A717_D103D354584F__INCLUDED_)
#define EA_B9C3BDB6_E1AE_4cf2_A717_D103D354584F__INCLUDED_

#include <map>
#include "ICommand.h"

namespace UI
{
  namespace CMD
  {
    class ControlCommand
    {

    public:
      enum ControlView
      {
        TEMPLATE_CTRL = 0,
        CHECKLIST_CTRL = 1,
        ITEM_CTRL = 2,
        CHOICE_CTRL = 3
      };

      virtual ~ControlCommand();
      /**
        * Singleton pattern for get control command object
        * @return control command object
        */
      static ControlCommand* GetInstance();
      /**
        * Delete the instance control command object when call the end program
        */
      static void Release();
      /**
        * Set command in list
        * @param command object
        */
      void SetCommand(ICommand* command);
      /**
        * Call the newchecklist , newtemplate , newchoice or newitem command
        * @param all type (TEMPLATE_CTRL , CHECKLIST_CTRL, CHOICE_CTRL or ITEM_CTRL)
        */
      void OnNew(ControlCommand::ControlView ctrlView);
      /**
        * Call the insertitem command  
        */
      void OnInsert();
      /**
        * Call the editchecklist , edittemplate , editchoice or edititem command
        * @param all type (TEMPLATE_CTRL , CHECKLIST_CTRL, CHOICE_CTRL or ITEM_CTRL)
        */
      void OnEdit(ControlView ctrlView);
      /**
        * Call the savechecklist , savetemplate or saveitem command
        * @param some type (TEMPLATE_CTRL , CHECKLIST_CTRL, CHOICE_CTRL or ITEM_CTRL)
        */
      void OnSave(ControlView ctrlView);
      /**
        * Call the backchecklist or backtemplate command
        * @param some type (TEMPLATE_CTRL or CHECKLIST_CTRL) that pass other type it do not happen anything
        */
      void OnBack(ControlView ctrlView);
      /**
        * Call the previewtemplate or previewchecklist command
        * @param some type (TEMPLATE_CTRL or CHECKLIST_CTRL) that pass other type it do not happen anything
        */
      void OnViewDetail(ControlView ctrlView);
      /**
        * Call the send mail command
        */
      void OnSendMail();

    protected:
      ControlCommand();

    private:
      static ControlCommand* g_cotrolCmdInstance;
      std::map<ICommand::CommandType, ICommand*> m_allCommands;

    };
  }
}

#endif // !defined(EA_B9C3BDB6_E1AE_4cf2_A717_D103D354584F__INCLUDED_)
